{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-form toolbar">
        <div class="layui-form-item">
            <form action="{:request()->url()}" class="layui-form" method="get">
                <div class="layui-inline text-right">
                    <div class="layui-input-inline mr0">
                        <input name="dateframe" class="layui-input" id="test16" value="{$dateframe}" type="text" autocomplete="off" placeholder="选择时间区间"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-warm ajax-search"><i class="fa fa-search"></i> 查看</button>
                </div>
            </form>
        </div>
    </div>
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableEditContract">
        {if auth_url('crm/contract/verify')}
        {{# if(d.status == '0'){ }}
        <a href="{:url('crm/contract/verify')}?id={{d.id}}" class="layui-btn layui-btn-sm layui-btn-warm ajax-action">审核</a>
        {{# } }}
        {/if}
        {if auth_url('crm/contract/edit')}
        <a href="{:url('crm/contract/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm ajax-iframe" data-width="50%" data-height="100%">修改</a>
        {/if}
        {if auth_url('crm/contract/del')}
        <a href="{:url('crm/contract/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a>
        {/if}
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="downfile">
        {{# if(d.file){}}
        <a href="{{d.file}}" class="layui-btn layui-btn-warm" target="_blank">下载合同</a>
        {{# }}}
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="time">
        开始时间：<button class="layui-btn layui-btn-primary">{{d.start_time}}</button><br>
        到期时间：<button class="layui-btn layui-btn-primary">{{d.end_time}}</button>
    </script>
    <!-- 合同图片 -->
    <script type="text/html" id="photo">
        <div class="layui-btn-group demoTest" style="margin-top: 5px;">
            <div class="paper-info-group-imgs" id="eDialogInfoImgs_hetong">
                {{#  layui.each(d.photo, function(index, item){ }}
                <img src="{{item}}" tb-img-circle tb-img height="80px">
                {{#  }); }}
            </div>
        </div>
    </script>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown','laytpl'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var dtree = layui.dtree;
        var admin = layui.admin;
        var dropdown = layui.dropdown;
        var index = layui.index;
        
        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('crm/analysis/user_json',['dateframe'=>$dateframe])}",
            page: true,
            cellMinWidth: 100,
            //toolbar:true ,
            limit:'15',
            limits:['15','30','50','100','200','500'],
            size:'lg',even:true,
            cols: [[
                {type:'numbers',title:'#'},
                {field: 'group_name', align: 'center', sort: true, title: '部门',width:120},
                {field: 'name', align: 'center', sort: true, title: '员工',width:120},
                {field: 'customer_count', align: 'center', sort: true, title: '客户数'},
                {field: 'track_count', align: 'center', sort: true, title: '回访客户'},
                {field: 'sales_sum', align: 'center', sort: true, title: '销售额'},
                {field: 'contract_count', align: 'center', sort: true, title: '新签合同'}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });
    });
</script>
<script>
    laydate.render({
        elem: '#test16'
        ,range: '-'
    });
</script>
{/block}